<template>
  <div class="screen-title">
    <div class="title-text">
      <h1><img src="../../assets/images/screen-title-text.png" alt=""></h1>
    </div>
    <div class="time-weather">
      <div class="time">14:25:58</div>
      <div class="content">
        <div class="date">2022年08月19日</div>
        <div class="weather">
          <i></i>
          <span>晴</span>
          <span>23℃</span>
        </div>
      </div>
    </div>
    <div class="nav-list">
      <ul>
        <li
          v-for="item,index in navList"
          :key="item.path"
          :class="{'active':index===navActiveIndex}"
          @click="handleNavTab(index)"
        >
          <router-link :to="item.path">{{item.name}}</router-link>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import _ from "lodash";
export default {
  name: "headerTop",
  mounted(){
    const $this = this
    const path = $this.$route.path
    const navIndex = _.findIndex($this.navList,(item)=>item.path===path)
    $this.navActiveIndex = navIndex
  },
  data(){
    return {
      navActiveIndex:0,
      navList:[{
        path:"/zongheTaishi",
        name:"综合态势"
      },{
        path:"/jinchuHuowu",
        name:"进出口货物"
      },{
        path:"/churujingRenkou",
        name:"出入境人口"
      },{
        path:"/bianminHushi",
        name:"边民互市"
      },{
        path:"/kouanMaoyi",
        name:"口岸贸易"
      },{
        path:"/kouanJiaotong",
        name:"口岸交通工具"
      },{
        path:"/anquanYunying",
        name:"安全与运营"
      }]
    }
  },
  methods:{
    handleNavTab(index){
      this.navActiveIndex = index
    }
  }
}
</script>

<style lang="scss" scoped>
.screen-title{
  height:80px;
  background-image: url(../../assets/images/title-bg.png);
  background-repeat: no-repeat;
  background-position: center;
  background-size: auto 100%;
  position: relative;
  .title-text{
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    h1{
      color: #fff;
      font-weight: normal;
      font-size: 32px;
      img{
        display: block;
        height: 50px;
      }
    }
  }
  .time-weather{
    position: absolute;
    top: 0;
    right: 20px;
    z-index: 1;
    height: 100%;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    .time{
      font-size: 28px;
      margin-right: 10px;
    }
    .content{
      .date{
        font-size: 12px;
      }
      .weather{
        display: flex;
        align-items: center;
        justify-content: flex-start;
        i{
          $width: 16px;
          width: $width;
          height: $width;
          background: {
            image: url(../../assets/images/icon-sunny.png);
            repeat: no-repeat;
            position: center;
            size: contain;
          }
        }
        span{
          font-size: 12px;
          margin-left: 10px;
        }
      }
    }
  }
  .nav-list{
    position: absolute;
    top: 70px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 9;
    user-select: none;
    ul{
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;
      padding: 0 20px;
      &::after,
      &::before{
        content:"";
        width: 28px;
        height: 28px;
        background: url(../../assets/images/header-border@2x.png) no-repeat center center / contain;
        position: absolute;
        top: 50%;
        left: 0;
        transform: translate(0,-50%);
      }
      &::after{
        left: initial;
        right: 0;
        transform: translate(0,-50%) rotate(180deg);
      }
      li{
        padding: 20px 0;
        a{
          height: 28px;
          padding: 0 16px;
          font-size: 18px;
          line-height: 28px;
          font-weight: normal;
          position: relative;
          color: #B5DBFF;
          &::after{
            content:"";
            width: 1px;
            height: 16px;
            background: #fff;
            position: absolute;
            top: 50%;
            left: 0;
            transform: translate(0,-50%);
            opacity: .3;
          }
          
        }
        &:first-child{
          a::after{
            display: none;
          }
        }
        &.active{
          background: url(../../assets/images/nav-active-bg@2x.png) no-repeat bottom center / 90% auto;
          a{
            color: #fff;
          }
        }
      }
    }
  }
}
</style>